﻿
* Save return2 (not excluding penny stocks) for future reference.;
libname save "D:\Dropbox\Work - RA\@ DATA\Testdata"; 
data base_testdata; set save.data_table2; where p_t1>=1; run; 



* Fit cross-sectional regression each period, compute number of stocks, and regression R2; 
ods select none; 
proc sort data=base_testdata; by t; run; 
proc glm data=base_testdata; 
	by t; 
	model mret=mret_t1 mret_t2 mret_t3 mret_t4 mret_t5 mret_t6 mret_t7 mret_t8 mret_t9 mret_t10 mret_t11 mret_t12; 
	ods output parameterestimates=est;
	ods output nobs=nobs; 
	ods output fitstatistics=stats;
run; quit; 
ods select all; 

proc transpose data=est out=est1; 
	by t; id parameter; var estimate;
run; 

data nobs; set nobs; where label='Number of Observations Used'; run; 
proc sql;
	create table out as
	select a.*, b.N, c.RSquare
	from est1 a 
		left join Nobs b on a.t=b.t
		left join stats c on a.t=c.t;
quit;
data out; set out; AdjRSquare=1-(1-RSquare)*(N-1)/(N-13); run; 

proc print data=out (drop = _name_); ; run; 
